<template>
    <div class="boxCard">
        <div class="dakaBtn" @click="punchCard">
            <p style="margin: 0;">{{ form.time }}</p>
            <p style="font-size: 32px;">打卡</p>
        </div>

        <div class="dakaInfo">
            <p>当前时间: {{ form.date }} {{ form.time }}</p>
            <p>
                <el-radio-group v-model="form.punchCardType">
                    <el-radio :label="1">上班卡</el-radio>
                    <el-radio :label="2">下班卡</el-radio>
                </el-radio-group>
            </p>

            <div v-if="form.week === 6 || form.week === 0" style="text-align: center;">
                <p style="font-weight: 500; color: red;">
                    当前是周{{ week == 6 ? '六' : '日' }},是否为加班卡
                </p>
                <el-radio-group v-model="form.overtime">
                    <el-radio :label="true">是</el-radio>
                    <el-radio :label="false">否</el-radio>
                </el-radio-group>
            </div>
        </div>
    </div>
</template>

<script>
import { addIssue } from "@/api/app";
import moment from "moment";
export default {
    data() {
        return {
            form: {
                punchCardType: 1,
                overtime: false,
                week: new Date().getDay(),
                date: moment().format("YYYY-MM-DD"),
                time: moment().format("HH:mm:ss"),
            },

            timer: null,
        };
    },

    mounted() {
        this.timedTask()
    },

    beforeDestroy() {
        this.closeTimer()
    },

    methods: {
        punchCard() {

        },

        timedTask() {
            if (this.timer) return
            this.timer = setInterval(() => {
                this.form.time = moment().format("HH:mm:ss");
            }, 1000);
        },

        closeTimer() {
            clearInterval(this.timer)
            this.timer = null
        }


    }
}
</script>

<style scoped>
.dakaInfo {
    width: 100%;
    height: 200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.dakaBtn {
    width: 200px;
    height: 200px;
    background-color: #0ea3ff;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
</style>